package com.fr.web.platform.entry;

import com.fr.base.core.json.JSONArray;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.schedule.ScheduleContext;
import com.fr.schedule.dao.FieldMapper;
import com.fr.schedule.dao.JdbcDaoManager;
import com.fr.schedule.dao.ObjectMapper;
import java.util.ArrayList;
import java.util.List;

public class FolderEntry extends BaseEntry
{
  public static final String TYPE_PREFIX = "0";
  public static final String TABLE_NAME = "fr_folderentry";
  public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper("fr_folderentry", new FieldMapper[] { new FieldMapper("id", 4, "id"), new FieldMapper("parentId", 4, "parent"), new FieldMapper("displayName", 12, "name"), new FieldMapper("description", 12, "description") });

  public FolderEntry()
  {
  }

  public FolderEntry(String paramString)
  {
    super(paramString);
  }

  public FolderEntry(String paramString1, String paramString2)
  {
    super(paramString1, paramString2);
  }

  public JSONObject createJSONConfig()
    throws JSONException
  {
    JSONObject localJSONObject1 = super.createJSONConfig();
    localJSONObject1.put("isexpand", true);
    localJSONObject1.put("complete", true);
    localJSONObject1.put("hasChildren", true);
    List localList = getChildFolderEntryList();
    if (localList.size() > 0)
    {
      JSONArray localJSONArray = new JSONArray();
      localJSONObject1.put("ChildNodes", localJSONArray);
      int i = 0;
      while (true)
      {
        if (i >= localList.size())
          break label121;
        Entry localEntry = (Entry)localList.get(i);
        JSONObject localJSONObject2 = localEntry.createJSONConfig();
        if (localJSONObject2 != null)
          localJSONArray.put(localJSONObject2);
        ++i;
      }
    }
    localJSONObject1.put("leaf", true);
    label121: return localJSONObject1;
  }

  public JSONArray createContentJSON()
    throws JSONException
  {
    JSONArray localJSONArray = new JSONArray();
    List localList = getContentEntryList();
    int i = 0;
    int j = localList.size();
    while (i < j)
    {
      localJSONArray.put(((Entry)localList.get(i)).createJSONConfig());
      ++i;
    }
    return localJSONArray;
  }

  public List getChildFolderEntryList()
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.addAll(listFolderEntrys());
    return localArrayList;
  }

  public List getContentEntryList()
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.addAll(listReportletEntrys());
    localArrayList.addAll(listURLEntrys());
    return localArrayList;
  }

  public List listFolderEntrys()
  {
    return ScheduleContext.getJdbcDaoManager().listByFieldValue(FolderEntry.class, "parentId", new Long(getId()));
  }

  public List listFileEntrys()
  {
    return ScheduleContext.getJdbcDaoManager().listByFieldValue(FileEntry.class, "parentId", new Long(getId()));
  }

  public List listReportletEntrys()
  {
    return ScheduleContext.getJdbcDaoManager().listByFieldValue(ReportletEntry.class, "parentId", new Long(getId()));
  }

  public List listURLEntrys()
  {
    return ScheduleContext.getJdbcDaoManager().listByFieldValue(URLEntry.class, "parentId", new Long(getId()));
  }

  public String getTypePrefix()
  {
    return "0";
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof FolderEntry))
      return false;
    return super.equals(paramObject);
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    FolderEntry localFolderEntry = (FolderEntry)super.clone();
    return localFolderEntry;
  }
}